<template>
  <div class="table">
    <div class="container">
      <div class="handle-box">
        设备名称：
        <el-input v-model="searchobj.devicename" class="handle-select mr10" placeholder="请输入内容"></el-input>设备编号：
        <el-input v-model="searchobj.code" class="handle-select mr10" placeholder="请输入内容"></el-input>日期：
        <el-date-picker
          v-model="searchobj.stime"
          align="right"
          type="date"
          placeholder="选择日期"
          :picker-options="pickerOptions"
        ></el-date-picker>&nbsp;&nbsp;
        至&nbsp;&nbsp;
        <el-date-picker
          v-model="searchobj.etime"
          align="right"
          type="date"
          placeholder="选择日期"
          :picker-options="pickerOptions"
        ></el-date-picker>&nbsp;&nbsp;
        <el-button type="primary" icon="el-icon-search">查询</el-button>
        <el-button type="success" icon="el-icon-clear" @click="clear">导出数据</el-button>
      </div>

      <el-table
        :data="tableData"
        border
        class="table"
        ref="multipleTable"

      >
        <el-table-column type="selection" width="55" align="center"></el-table-column>
        <el-table-column prop="gsname" label="热力公司"></el-table-column>
        <el-table-column prop="sousename" label="热源"></el-table-column>
        <el-table-column prop="sitename" label="换热站"></el-table-column>
        <el-table-column prop="groupname" label="机组"></el-table-column>
        <el-table-column prop="areaname" label="小区"></el-table-column>
        <el-table-column prop="louname" label="楼宇"></el-table-column>
        <el-table-column prop="number" label="门牌号"></el-table-column>

        <el-table-column prop="code" label="设备编号" ></el-table-column>
        
        <el-table-column prop="wendu" label="监测温度" :formatter="formatter"></el-table-column>
        <el-table-column prop="shidu" label="检测湿度" :formatter="formatter"></el-table-column>
        <el-table-column prop="createtime" label="报警日期" ></el-table-column>

      
      </el-table>
      <div class="pagination">
        <el-pagination
          background
          @current-change="handleCurrentChange"
          layout="prev, pager, next,jumper"
          :total="allcount"
          :page-size="size"
          :current-page.sync="cur_page"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "basetable",
  data() {
    return {
      url: "./vuetable.json",
      tableData: [],
      cur_page: 1,
      size: 10,
      multipleSelection: [],
      select_cate: "",
      select_word: "",
      del_list: [],
      is_search: false,
      addVisible: false,
      editVisible: false,
      delVisible: false,
      idx: -1,
      searchobj: {},
      addobj: {},
      editobj: {},
      allcount: 0,
      count: 0
    };
  },
  created() {
    this.getData();
  },
  computed: {
    data() {
     
    }
  },
  methods: {
    // 分页导航
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getData();
    },
    // 获取 easy-mock 的模拟数据
    getData() {
      // 开发环境使用 easy-mock 数据，正式环境使用 json 文件
      this.$axios
        .post(this.$api + "admin/errlog/list", {
          page: this.cur_page,
          size: this.size
        })
        .then(res => {
          this.tableData = res.data.data.list;
          this.allcount = res.data.data.allcount;
          this.count = res.data.data.count;
        });
    },
    clear(){

    },
    pickerOptions() {},
    search() {
      this.is_search = true;
    },
    formatter(row, column) {
      return row.address;
    },
    filterTag(value, row) {
      return row.tag === value;
    },

    handleDelete(index, row) {
      this.idx = index;
      this.delVisible = true;
    },

    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    deleteRow() {
      this.$axios
        .post(this.$api + "admin/device/del", this.editobj)
        .then(res => {
          if (res.data.status == 200) {
            this.$message.success(res.data.message);
            this.getData();
          } else {
            this.$message.error(res.data.message);
          }
          this.delVisible = false;
        });
    }
  }
};
</script>

<style scoped>
.handle-box {
  margin-bottom: 20px;
}

.handle-select {
  width: 120px;
}

.handle-input {
  width: 300px;
  display: inline-block;
}
.del-dialog-cnt {
  font-size: 16px;
  text-align: center;
}
.table {
  width: 100%;
  font-size: 14px;
}
.red {
  color: #ff0000;
}
.mr10 {
  margin-right: 10px;
}
</style>
